FROM m.daocloud.io/docker.io/nvidia/cuda:11.8.0-devel-ubuntu22.04
LABEL maintainer="HanBing"

ENV DEBIAN_FRONTEND=noninteractive

# 安装Python 3.9
RUN apt-get update && apt-get install -y --no-install-recommends \
    software-properties-common \
    && add-apt-repository ppa:deadsnakes/ppa -y \
    && apt-get update && apt-get install -y --no-install-recommends \
    python3.9 \
    python3.9-distutils \
    python3.9-dev \
    && rm -rf /var/lib/apt/lists/* \
    && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.9

# 设置软链接，让python和python3都指向python3.9
RUN ln -s /usr/bin/python3.9 /usr/bin/python && \
    ln -sf /usr/bin/python3.9 /usr/bin/python3

WORKDIR /root/repo

ADD . .
ADD pyvenv.cfg /root/repo/.venv/pyvenv.cfg

RUN rm /root/repo/.venv/bin/python \
    && ln -s /usr/bin/python3.9 /root/repo/.venv/bin/python

RUN /root/repo/.venv/bin/python scripts/download_models.py

ENTRYPOINT ["/root/repo/.venv/bin/python"]